#include <condition_variable>
#include <mutex>
#include <queue>

#include "bridge/MessageQueue.h"

namespace test_bridge {
using namespace bridge;

class MyMessageQueue : public MessageQueue {
 public:
  MyMessageQueue(std::string queueName) : queueName_(queueName) {}

  void runOnQueue(std::function<void()>&& func) override;

  void execute();

  size_t size() {
    std::lock_guard<std::mutex> lock(mutex_);
    return queue_.size();
  }

  bool isEmpty() {
    std::lock_guard<std::mutex> lock(mutex_);
    return queue_.empty();
  }

 private:
  std::queue<std::function<void()>> queue_;
  mutable std::mutex mutex_;
  std::condition_variable cond_;
  std::string queueName_;
};
}  // namespace test_bridge